/*----------------------------------------------------------------------------*\
| /gamemode/cl_etc.lua                 | various client-side functions   | CLI |
\*----------------------------------------------------------------------------*/

etc = {}

etc.Hurting       = 0 
etc.Pos = Vector( 0 , 0 , 0 )
etc.Ang = Vector( 0 , 0 , 0 )
etc.Field = 0
etc.Fov = 0
MYFOV = 90
TARGETFOV = 90
FOVOVERRIDE=false
FOVBOOST=0

function GM:CalcView(ply,pos,ang,field)
	local view = {}
	
	if !LocalPlayer():IsRagdolled() then
		
		view = self.BaseClass:CalcView( ply, pos, ang, field )
		
		if MYFOV < TARGETFOV then
			
			MYFOV=math.Approach( MYFOV, TARGETFOV, MYFOV * (1.1 + FOVBOOST) / TARGETFOV )
			
			if MYFOV >= TARGETFOV then
			
				if (!FOVOVERRIDE) then
				
					TARGETFOV = 90 
					
				end
				
			end
			
		elseif MYFOV > TARGETFOV then
		
			MYFOV = MYFOV - 1
			
		end
		view.fov=MYFOV
	else
		local rag=LocalPlayer():GetNetworkedEntity("myragdoll")
		if (rag:IsValid()) then
			local eyes=rag:GetAttachment(rag:LookupAttachment("eyes"))
			MYFOV=math.Approach(MYFOV,160,0.15)
			view.origin=			eyes.Pos
			view.angles=			eyes.Ang
			view.fov=				MYFOV
		end
	end
	
	return view
end

function etc.DisableFlashlight( pl, bind )
	if bind == "impulse 100" then
		return true
	end
end
hook.Add( "BindPress", "DisableFlashlight", etc.DisableFlashlight )

function GM:AdjustMouseSensitivity(n)
	if (LocalPlayer():GetActiveWeapon().Mode == WEAPON_SCOPED and LocalPlayer():GetActiveWeapon():GetNetworkedBool( "Ironsights" )) then
		return 0.1
	else
		return -1
	end
end

// Get the SVN version from the client
local function GetSVNRevision(um)
	ZDayConfig["version"] = um:ReadShort()
	print("ZDAYCONFIG[VERSION] = " .. ZDayConfig["version"] )
end
usermessage.Hook("RecvSVNRevision", function( um ) GetSVNRevision( um ) end)

function UpdateHurting( um )
	etc.Hurting = um:ReadShort()
end
usermessage.Hook("Updatehurt", UpdateHurting) 

function UpdateFOVvals( um )
	TARGETFOV = um:ReadFloat()
	FOVBOOST = um:ReadFloat()
end
usermessage.Hook("UpdateFOV", UpdateFOVvals) 




